// 重写数组的方法 push/shift/unshift/pop/reverse/sort/splice
let oldArrayMethods = Array.prototype;
export let arrayMethods = Object.create(oldArrayMethods);
const methods = [
    'push',
    "shift",
    "unshift",
    "pop",
    "reverse",
    "sort",
    "splice"
]
methods.forEach( method => {
    arrayMethods[method] = function (...args) {
        const result = oldArrayMethods[method].apply(this,args);
        let inserted;
        let ob = this.__ob__;
        switch (method) {
            case 'push':
                break;
            case 'shift':
                break;
            case 'unshift':
                inserted = args;
                break;
            case 'pop':
                break;
            case 'reverse':
                break;
            case 'sort':
                break;
            case 'splice':
                inserted = args.splice(2)
                break;
            default:
                break;
        }
        if(inserted)ob.observerArray(inserted); // 当新增属性继续观测
        return result;
    }
})
